<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
    
    
    <?php
    $conn=@mysql_connect("localhost","root","")  or die(mysql_error());
     mysql_query("SET NAMES UTF8");
     @mysql_select_db('guyueyan',$conn) or die(mysql_error()); 
    
     if(isset($_POST['ann'])){
        
        if(isset($_POST['acc']))
            $acc = $_POST['acc'];       //账户名
         
         if(isset($_POST['code']))
            $code = $_POST['code'];     //密码
         
         if($acc == "1963110"){    //判断是否是管理员
             if($code=="zxcv"){
                 echo '<script>alert("欢迎管理员！")</script>';
                 Header("Location:/testing/pages/manage.php"); 
                 exit();
             }
         }else{
             $k=0;   //判断是否找到该账户
             $select1 = "select account from user";
             $use = mysql_query($select1);
             while($accs =mysql_fetch_row($use) ){
                 if($accs[0] == $acc){  
                    $k=1;     //找到了
                    break;
                 }  
             }
             if($k==0){
                echo '<script>alert("账户不存在！")</script>';
                 exit();
             }
                
         }
         
        
        
        $select2 = "select password,id from user where account='$acc'";
        $sum = mysql_query($select2);
         
         $as = mysql_fetch_row($sum);
         print_r($sum);
         $pass = $as[0];
         $id = $as[1];
         
        if($pass!=$code){
            
            echo '<script>alert("密码错误！")</script>';
            exit();
        }else
         echo '<script>alert("登录成功！")</script>';
         Header("Location:/testing/pages/main.php?id=$id"); 
        }
    ?>
    
</body>
</html>